package com.yc.cloudvideo.sp_file.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.yc.cloudvideo.entity.Danmu;
import com.yc.cloudvideo.sp_file.mapper.DanmuMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LYYT
 * @since 2022-08-06
 */
@RestController
@RequestMapping("/cloudvideo/danmu")
public class DanmuController {
    @Resource
    private DanmuMapper danmuMapper;

    @RequestMapping("queryDanmu")
    public List<Danmu> queryDanmu(@RequestParam String fid){
        LambdaQueryWrapper<Danmu> lwq=new LambdaQueryWrapper<>();
        lwq.eq(Danmu::getFid,fid);
        lwq.orderByAsc(Danmu::getTime);
        return  danmuMapper.selectList(lwq);
    }

    @RequestMapping("saveDanmu")
    public int saveDanmu(
            long uid,
            @RequestParam Long fid,@RequestParam String body,
                         @RequestParam String colour,@RequestParam Double time){
        Danmu danmu=new Danmu();
        danmu.setUid(uid);
        danmu.setFid(fid);
        danmu.setBody(body);
        danmu.setColour(colour);
        danmu.setTime(time);
        return  danmuMapper.insert(danmu);
    }
}

